package com.forekonw.demotest1029;

public class Order {
    private int number;
    private double amount;
    private Book[] books;
    private OrderItem[] orderltems;

    public Order() {
        books = new Book[3];
        orderltems = new OrderItem[3];
    }
//订单编号及总金额
    public double allmoney(int number,int count) {
        double allmoney = 0.0;
        for (int i = 0 ;i<books.length;i++){
            double money = 0.0;
                if (number == books[i].getBno()) {
                    money = books[i].getBmoney();
                    allmoney = count * money;//一个
                    break;
                }
        }
        return allmoney;
    }
//图书列表
    public void books(){
        Book b1 = new Book("java",1,33.45,50);
        Book b2 = new Book("jsp",2,55.45,150);
        Book b3 = new Book("ssm",3,77.45,250);
//        Book[] books = new Book[3];
        books[0] = b1;
        books[1] = b2;
        books[2] = b3;
        for (int i =0 ;i < books.length;i++){
            System.out.println(books[i].getBno()+"   "+books[i].getBname()+"   "+books[i].getBmoney()+"   "+books[i].getStock());
        }
    }
//最下面输出的购买列表
    public OrderItem orderltems(int number , int count){
        OrderItem[] arr = new OrderItem[3];
        OrderItem order = new OrderItem();
        for (int i =0 ; i < arr.length ; i ++){
            if (books[i].getBno()==number){
                String name = books[i].getBname();
                double money = books[i].getBmoney();
                OrderItem oo = new OrderItem(name,money,count);
                order = oo;
            }
        }
        return order;
    }

    public int getNumber() {
        return number;
    }

    public void setNumber(int number) {
        this.number = number;
    }

    public double getAmount() {
        return amount;
    }

    public void setAmount(double amount) {
        this.amount = amount;
    }

    public Book[] getBooks() {
        return books;
    }

    public void setBooks(Book[] books) {
        this.books = books;
    }
}


